package com.woniuxy.infrastructure.controller;

import com.woniuxy.infrastructure.pojo.Light;
import com.woniuxy.infrastructure.service.LightService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/light")
@AllArgsConstructor
public class LightController {
    private final LightService lightService;

    // 查询全部light
    @GetMapping("/all")
    public List<Light> getAllLights() {
        return lightService.list();
    }

    // 更新灯光使用状态
    @PutMapping("/{id}/used")
    public boolean updateUsedStatus(@PathVariable Long id, @RequestParam Integer used) {
        return lightService.updateUsedStatus(id, used);
    }

    // 添加灯光
    @PostMapping("/add")
    public boolean addLight(@RequestBody Light light) {
        return lightService.save(light);
    }
} 